package com.jason.canvas.view;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;

/**
 * @DESC: canvas的clip的使用
 * @Author: Jason
 * @Date: 16/9/18
 * @Time: 16:08
 */

public class CanvasView3 extends View {


    private Paint mPaint;

    public CanvasView3(Context context, AttributeSet attrs) {
        super(context, attrs);

        mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        mPaint.setStyle(Paint.Style.FILL);
        mPaint.setColor(Color.GREEN);

    }

    @Override
    protected void onDraw(Canvas canvas) {
        canvas.drawColor(Color.BLUE);
        // 从左端点开始裁剪出一块500*500大小的矩形将其绘制成红色
        canvas.clipRect(0, 0, 500, 500);
        canvas.drawColor(Color.RED);
        canvas.drawCircle(500, 500, 100, mPaint);


    }
}
